package com.linkoog.devtools.code_generator.database.dao;

import com.linkoog.devtools.code_generator.database.domain.ConnectionInfo;
import com.linkoog.devtools.code_generator.database.domain.DbType;
import com.linkoog.devtools.code_generator.database.dao.db.MysqlDatabaseDao;
import com.linkoog.devtools.code_generator.database.dao.db.OracleDatabaseDao;
import com.linkoog.devtools.code_generator.database.dao.db.PostgreDatabaseDao;
import org.jetbrains.annotations.NotNull;

public class DatabaseDaoFactory {

    public static DatabaseDao create(@NotNull ConnectionInfo connectionInfo){
        DbType dbType = connectionInfo.getDbType();
        switch (dbType){
            case MYSQL: return new MysqlDatabaseDao(connectionInfo);
            case ORACLE: return new OracleDatabaseDao(connectionInfo);
            case POSTGRE: return new PostgreDatabaseDao(connectionInfo);
            default: throw new IllegalStateException("不支持该数据库");
        }
    }
}
